package com.juyu.miliao.scheduler.dao.redis;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Repository;

/**
 * 主播等级redis
 * @Auther: 卜加超
 * @Date: 2019/8/20 09:25
 * @Description:
 */
@Repository
public class UserIntegralRedis {
    private static final String  USER_INTEGRAL_STRING_KEY = "USER_INTEGRAL_STRING:";

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    public boolean checkIsUserIntegral(long userId){
        String key = USER_INTEGRAL_STRING_KEY+userId;
      return  stringRedisTemplate.hasKey(key);
    }

    public void addUserIntegral(long userId,int num){
        String key = USER_INTEGRAL_STRING_KEY+userId;
        stringRedisTemplate.opsForValue().set(key,num+"");
    }

    public String getUserIntegral(long userId){
        String key = USER_INTEGRAL_STRING_KEY+userId;
        return  stringRedisTemplate.opsForValue().get(key);
    }
}
